/*
 * @Author: moonwater 13812995013@163.com
 * @Date: 2025-03-04 16:12:55
 * @LastEditors: moonwater 13812995013@163.com
 * @LastEditTime: 2025-03-04 16:13:24
 * @FilePath: \盐师22Git仓库\Month.java
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import java.util.Scanner;
 
public class Month {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        System.out.print("请输入月份（1-12）：");
        int month = scanner.nextInt();
        
        try {
            String season = determineSeason(month);
            System.out.println("该月份属于：" + season);
        } catch (IllegalArgumentException e) {
            System.out.println(e.getMessage());
        }
        
        scanner.close();
    }
    
    /**
     * 根据月份确定季节
     * @param month 月份（1-12）
     * @return 季节名称
     * @throws IllegalArgumentException 如果月份不在1到12之间，则抛出异常
     */
    public static String determineSeason(int month) {
        if (month < 1 || month > 12) {
            throw new IllegalArgumentException("输入月份有误");
        }
        
        String season;
        if (month >= 12 || month <= 2) {
            season = "冬季";
        } else if (month >= 3 && month <= 5) {
            season = "春季";
        } else if (month >= 6 && month <= 8) {
            season = "夏季";
        } else { // month >= 9 && month <= 11
            season = "秋季";
        }
        
        return season;
    }
}